#include <stdio.h>
#include <locale.h>
#include <libguile.h>

int main(int argc, const char *argv[])
{
        SCM scm_func;
        SCM scm_ret_val;
        int val;
        
        setlocale(LC_ALL, "");

        scm_init_guile();       //在任何其他Scheme函数之前调用
        scm_c_primitive_load("script.scm"); //装载scheme文件

        scm_func = scm_variable_ref(scm_c_lookup("square")); //查找指定变量并保存到func中
        scm_ret_val = scm_call_1( scm_func, scm_from_int(9)); //调用func指定的函数
        val = scm_to_int(scm_ret_val);
        printf("%s:result of square is %d\n",__func__, val);
        
        scm_c_define("s_arg", scm_from_stringn("Hello world", 12, 0, SCM_FAILED_CONVERSION_ERROR));
        scm_func = scm_variable_ref(scm_c_lookup("show"));
        scm_call_0(scm_func);

        return 0;
}
